home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 71
/
MOBICLIC 71.ISO
/
mac
/
DATA
/
COMMUN
/
temp0001
/
00009_Script_moteurs
< prev
next >
Wrap
Text File
|
2004-12-05
|
17KB
|
574 lines
-- affiche un Θlastique entre un objet origine et un objet cible
global traitLiaison, volumeOn, menuOuvert
on initTraitLiaison sPoint,remplacement
-- initialisation d'une procΘdure traitLaison
-- sPoint est le numΘro de la piste portant le point mobile (ex: acteur TrL Point de menu.cst)
-- remplacement : si 0 l'acteur de la piste sPoint est utilisΘ, 1 il est remplacΘ par l'acteur
-- de la piste s
global traitLiaison
cursor 290
set s = the currentSpriteNum
set x = the mouseH
set y = the mouseV
if the paramCount =1 then
set remplacement=0
end if
jingle( 3, "poc", "OUT")
set the rect of sprite (sPoint -1) to rect(x,y,x,y)
set the locH of sprite sPoint = x
set the locV of sprite sPoint = y
if remplacement = 1 then
sprite(sPoint).member = sprite(s).member
end if
afficherPistes (sPoint -1),sPoint
set traitLiaison = [s,x,y]
updateStage
end
on traitLiaison p1,p2,p3
-- p1 : piste du trait pente 1 (ex : acteur Trl 1 de la distribution menus.cst)
-- p2 : piste du trait pente -1 (ex : acteur TrL -1 de la distribution menus.cst)
-- p3 : piste du point mobile (ex : acteur TrL Point de la distribution menus.cst)
-- la variable liste traitLiaison contient :
---- 1 : piste de l'objet origine
---- 2 : locH de l'objet origine
---- 3 : locV de l'objet origine
set the locH of sprite p3 = the mouseH
set the locV of sprite p3 = the mouseV
set H = the locH of sprite p3
set V = the locV of sprite p3
if V < getAt(traitLiaison,3) then
-- le point de choix est plus haut que l'objet de dΘpart
set y1 = V
set y2 = getAt(traitLiaison,3)
if abs(y1-y2)<4 then set y2 = y1 + 4
if H > getAt(traitLiaison,2) then
-- le point de choix est α droite de l'objet de dΘpart
set h1 = getAt(traitLiaison,2)
set h2 = h
if abs(h1-h2)<4 then set h2 = h1 + 4
afficherPistes p1
masquerPistes p2
set the rect of sprite p1 to rect(h1,y1,h2,y2)
else
-- le point de choix est α gauche de l'objet de dΘpart
set h1 = h
set h2 = getAt(traitLiaison,2)
if abs(h1-h2)<4 then set h2 = h1 + 4
afficherPistes p2
masquerPistes p1
set the rect of sprite p2 to rect(h1,y1,h2,y2)
end if
else
-- le point de choix est plus bas que l'objet de dΘpart
set y1 = getAt(traitLiaison,3)
set y2 = V
if abs(y1-y2)<4 then set y2 = y1 + 4
if H > getAt(traitLiaison,2) then
-- le point de choix est α droite de l'objet de dΘpart
set h1 = getAt(traitLiaison,2)
set h2 = h
if abs(h1-h2)<4 then set h2 = h1 + 4
afficherPistes p2
masquerPistes p1
set the rect of sprite p2 to rect(h1,y1,h2,y2)
else
-- le point de choix est α gauche de l'objet de dΘpart
set h1 = h
set h2 = getAt(traitLiaison,2)
if abs(h1-h2)<4 then set h2 = h1 + 4
afficherPistes p1
masquerPistes p2
set the rect of sprite p1 to rect(h1,y1,h2,y2)
end if
end if
updateStage
end
on glisserDeposer s1,s2,s3,s4,mode
-- s1 : est la piste cible de plus bas numΘro
-- s2 : est la piste cible de numΘro le plus ΘlevΘ
-- s3 : piste acteur α dΘplacer de plus bas numΘro
-- s4 : piste point en bout d'Θlastique
-- mode : l'objet dΘplacΘ est supprimΘ si valeur 1, laissΘ en place si 0
if the paramCount =3 then
set mode = 0
end if
global traitLiaison, choix
if the visible of sprite s4 = 1 then
cursor -1
set s = getAt(traitLiaison,1)
repeat with i = s1 to s2
if sprite s4 intersects i then
-- emplacement occupΘ ? ------------------------------------
if getAt(choix,i+1-s1)<>0 then
if mode = 1 then
afficherPistes s3-1+getAt(choix,i-s1+1)
end if
end if
-- mise en place de l'ΘlΘment glissΘ -----------------------
set the memberNum of sprite i = the memberNum of sprite s4
updateStage
setAt choix,i-s1+1,s-s3+1
afficherPistes i
if mode = 1 then
masquerPistes s
end if
updateStage
puppetSound 2, "poc"
exit repeat
end if
end repeat
masquerPistes s4-2,s4-1,s4
-- l'ΘlΘment dΘposΘ n'est en intersection avec aucune zone
if i=1+s2 then
jingle( 2, "echec_01", "OUT")
end if
end if
end
on controlePanier
-- ce script est α recopier et placer dans un bouton au mouseUp
-- les valeurs utilisΘes sont indicatives
global choix
set L =[[1,2,3],[4,5,6],[7,8,9],[10,11,12],[13,14,15]]
-- s1 = numΘro de la piste cible de plus bas numΘro
set s1 = 20
-- s2 = numΘro de la piste acteur α glisser la plus basse
set s2 = 40
set test = 0
-- test du premier panier --------------------------
set L1 = getAt(L,1)
repeat with i=1 to 3
if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
set test = 1
afficherPistes s2-1+getAt(choix,i)
masquerPistes s1-1+i
setAt choix,i,0
end if
end repeat
-- test du deuxiΦme panier --------------------------
set L1 = getAt(L,2)
repeat with i=4 to 6
if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
set test = 1
afficherPistes s2-1+getAt(choix,i)
masquerPistes s1-1+i
setAt choix,i,0
end if
end repeat
-- test du troisiΦme panier --------------------------
set L1 = getAt(L,3)
repeat with i=7 to 9
if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
set test = 1
afficherPistes s2-1+getAt(choix,i)
masquerPistes s1-1+i
setAt choix,i,0
end if
end repeat
-- test du quatriΦme panier ---------------------------
set L1 = getAt(L,4)
repeat with i=10 to 12
if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
set test = 1
afficherPistes s2-1+getAt(choix,i)
masquerPistes s1-1+i
setAt choix,i,0
end if
end repeat
-- test du cinquiΦme panier -----------------------------
set L1 = getAt(L,5)
repeat with i=13 to 15
if (getAt(choix,i)<>getAt(L1,1)) and (getAt(choix,i)<>getAt(L1,2)) and (getAt(choix,i)<>getAt(L1,3)) then
set test = 1
afficherPistes s2-1+getAt(choix,i)
masquerPistes s1-1+i
setAt choix,i,0
end if
end repeat
-- controle final -----------------------------------------
if test=0 then
-- son de rΘussite α placer ici
go to "fin"
else
jingle( 2, "echec_01","OUT")
end if
end
-------------------------------------------------------------
-- test clic sur Θcran
on testClic
global gJLM_W
if the pauseState = 0 and gJLM_W = 0 then
return 1
else
return 0
end if
-------------------------------------------------------------------------
-- repΘrage de coordonnΘes d'acteurs sur la scΦne
on posXY a,b
-- un champ nommΘ "locHV" doit exister dans la distribution interne
repeat with i= a to b
put the locH of sprite i into word 1 of line(i-a+1) of field "locHV"
put the locV of sprite i into word 2 of line(i-a+1) of field "locHV"
end repeat
end
------------------------------------------------------
on imprime
-- impression de l'Θcran
prevue = the optionDown
doc = xtra("PrintOMatic").new()
-- if not objectP(doc) then exit
-- setPrintableMargins doc
pipeline = xtra("FILEXtra4").new()
target = pipeline.fx_FolderGetSpecialPath("kDesktopFolderType")
member("TAMPON_ECRAN").picture = the stage.picture
-- exportPicture("TAMPON_ECRAN",target&"MOBIPRINT_TEMP.jpg")
-- open "@//WIN98PRINTER/WIN98PRINTER"
if doPageSetUp (doc) = true then
newPage doc
H = getPageWidth(doc)
V = getPageHeight(doc)
X =(H-640)/2
Y =(V-480)/2
if H>=640 then
drawStagePicture doc, Point(X,Y),Rect(1,1,640,480),true
else
drawStagePicture doc, rect(1,1,H,V),Rect(1,1,640,480),true
end if
if doJobSetup (doc) = TRUE then
if prevue = 1 then
printPreview doc
else
setProgressMsg doc , "Impression d'un Θcran Mobiclic en cours... "
print doc
end if
end if
end if
doc = 0
end imprime
--------------------------------------------------------------------
-- impression d'un acteur
on imprimeActeur n,c
if the paramCount=1 then
set c=1
end if
set prevue = the optionDown
if prevue=1 then
printPreview member n of castLib c
else
print member n of castLib c
end if
end imprimeActeur
-- impression d'une planche de cartes
-- la zone placΘe sous le rectangle de la piste s est imprimΘe en optimisant
-- le remplissage de la feuille (portrait ou paysage)
on imprimeCartes s
updateStage
set prevue = the optionDown
-- gΘnΘrer le fichier impression si validation du format d'impression
doc = xtra("PrintOMatic").new()
if not objectP(doc) then exit
setPrintableMargins doc
if doPageSetUp (doc) = true then
newPage doc
H = getPageWidth(doc)
V = getPageHeight(doc)
H2 = 10+sprite(s).width
V2 = 10+sprite(s).height
nx = H/H2
ny = V/V2
r = sprite(s).rect
repeat with y = 1 to ny
repeat with x = 1 to nx
drawStagePicture doc, Point(1+(x-1)*H2,1+(y-1)*V2),r,true
end repeat
end repeat
if prevue=1 then
if doJobSetup (doc) = TRUE then
printPreview doc
end if
else
if doJobSetup (doc) = TRUE then
setProgressMsg doc , "Impression en cours... "
print doc
end if
end if
end if
doc = 0
end
-- temporisation (en secondes)
on temporise t
t= t*60.0
d = the timer
repeat while the timer - d < t
end repeat
end temporise
-- conversion d'un chemin d'accΦs de Mac α Dos
on nomDos nom
if the machineType = 256 then
repeat with i=1 to the number of chars of nom
if char i of nom = ":" then
put "\" into char i of nom
end if
end repeat
end if
return nom
end nomDos
-- affichage successif des pistes d'un groupe de pistes
on choixElements a,b,mode,s
-- gΦre l'affichage alternatif d'une piste parmi un groupe
-- de pistes dont les numΘros sont compris entre a et b
-- mode : 0 passage par un Θtat vide, 1 pas d'Θtat vide
-- son : 0 pas de son poc, 1 son activΘ (1 par dΘfaut)
case the paramCount of
2:set mode=0
set s=1
3:set s=1
end case
repeat with i=a to b
if the visible of sprite i=1 then
exit repeat
end if
end repeat
if i=b+1 then
-- aucune piste n'est affichΘe
set piste=a
else
if i=b then
-- derniΦre piste affichΘe : selon mode
if mode=0 then
set piste=value(field "PPGS")
else
set piste=a
end if
else
-- cas gΘnΘral : afficher la piste suivante
set piste=i+1
end if
end if
-- dissimulation de toutes les pistes
repeat with i=a to b
masquerPistes i
end repeat
-- affichage de la bonne piste
if piste<>value(field "PPGS") then
afficherPistes piste
end if
if s=1 then
sound(2).play(member "poc")
end if
end
-- tirage d'une liste alΘatoire
on randomList nbreElts, nbreMaxi
-- tirage alΘatoire d'une liste de nombres dont le nombre d'ΘlΘments est nbreElts
-- et dont chaque valeur est comprise entre 1 et nbreMaxi
---- nbreElts = le nombre d'ΘlΘments de la liste
---- nbreMaxi = nombre maximum pouvant Ωtre incorporΘ α la liste
randomList=[]
if the paramCount=1 then
nbreMaxi=nbreElts
end if
if nbreElts>0 then
repeat while count(randomList)<nbreElts
r = random(nbreMaxi)
if getPos(randomList,r)=0 then
append randomList, r
end if
end repeat
end if
return randomList
end
-- positions dans liste
on positionsListe liste1
-- α partir de la liste liste1 construit liste2 telle que les ΘlΘments de liste2
-- sont les positions occupΘes par les nombres de 1 α n dans liste1
n = count(liste1)
liste2=[]
liste2[n] = 0
repeat with i=1 to n
p = getPos(liste1,i)
liste2[i]=p
end repeat
return liste2
end
-- somme des termes d'une liste
on sommeListe L
somme = 0
repeat with i=1 to count(L)
somme = somme + L[i]
end repeat
return somme
end
-- envoi direct d'un mouseUp α une image objet
on click piste
-- passe le message mouseUp α l'image objet piste
mouseUp(script (the scriptNum of sprite piste))
end
-- teste la visibilitΘ d'un groupe de pistes
on test piste1,piste2
testM=0
repeat with i=piste1 to piste2
testM = testM + sprite(i).visible
end repeat
return testM
end
-- calcul de la distance entre deux points
on distance x1,y1,x2,y2
-- calcule la distance entre un point de coordonnΘes (x1,y1)
-- et un point de coordonnΘes (x2,y2)
d = sqrt(power(abs(x1-x2),2)+power(abs(y1-y2),2))
return d
end
-- calcul d'angle
on calculAngle centre
-- centre : numΘro de la piste du point marquant le centre de la rotation
x1 = the mouseH
y1 = the mouseV
x0 = the locH of sprite centre
y0 = the locV of sprite centre
if x1=x0 then
if y1<y0 then
alpha0 = 0
else
alpha0 = 180
end if
else
tgalpha = 1.0*(Y1-Y0)/(X1-X0)
alpha = atan(tgalpha)
alpha0 = alpha*180/pi()
-- calcul de la valeur rΘelle de l'angle
if x1>x0 then
alpha0=90+alpha0
end if
if x1<x0 then
alpha0=270+alpha0
end if
end if
return alpha0
end
-- conversion de degrΘs en radians
on convDegRad deg
rad = (deg*(PI))/180.0
return rad
end
-- Importation d'un fichier dans un acteur (nΘcessite fileXtra)
on importer numActeur, type
-- numActeur est le numΘro de l'acteur dans lequel
-- doit avoir lieu l'importation
-- teste le numΘro d'acteur pour l'importation
if value(numActeur)=0 then exit
-- controle de la prΘsence d'un type de fichier
if the paramCount=1 then
set type=""
else
set type=string(type)
end if
-- affichage d'une boεte de dialogue ouvrir
put fileopenDialog("",type) into nom
if nom<> "" then
importFileInto member numActeur, nom
end if
end importer
-- Enregistrement d'un fichier texte sur le disque
on enregistre acteur,texte1,texte2,mode
-- nΘcessite fileIO et fileXtra
-- acteur : numΘro de l'acteur texte α enregistrer
-- texte1 : nom de fichier par dΘfaut
-- texte2 : message de la boεte de dialogue
-- mode : 0 affiche une boite de dialogue
-- 1 enregistre l'acteur au mΩme niveau que le film
-- 2 enregistre l'acteur dans le dossier systΦme
if the paramCount=3 then
set mode =0
end if
case mode of
0:-- affichage d'une boεte de dialogue enregistrer sous
put FileSaveAsDialog(the pathName, texte1, texte2) into cible
1:-- enregistrement au niveau du film
set cible = the pathName & texte1
2:-- enregistrement dans le dossier systΦme
if the machineType = 256 then
set cible = getOsDirectory() & "\" & texte1
else
set cible = getOsDirectory() & texte1
end if
end case
if cible<>"" then
set enreg = new(xtra "fileIO")
createFile(enreg,cible)
openFile(enreg,cible,2)
set chaine = field acteur
writeString(enreg, chaine)
closeFile(enreg)
end if
end
-- donne le volume de dΘmarrage
on disqueBoot
if the machineType=256 then
volume = baSysFolder("windows")
set disque = volume.char[1..3]
else
volume = baSysFolder("prefs")
set disque = volume.char[1..(offset(":", volume)-1)]
end if
return disque
end
-- donne l'espace disponible sur le volume de dΘmarrage
on espaceDisque disque
return baDiskInfo(disque, "free")
end
-- copie des textes sur le disque dur
on textes
global chemin,cheminTextes
set lTextes=0
-- repΘrage du chemin d'accΦs au bureau (nΘcessite buddy API)
set disque=baSysFolder("desktop")
-- crΘation d'un dossier sur le bureau (nΘcessite filextra)
if the machineType<>256 then
-- sur Mac
set nom = disque & "textesMobiclic:"
createdirectory nom
set lTextes=1
else
if the platform="Windows,32" then
-- sous Windows 95 et 98
set nom = disque & "textesMobiclic\"
createdirectory nom
set lTextes=2
end if
end if
-- copie des textes sur le disque dur
XcopyDirectory cheminTextes, nom
-- message d'alerte
alert line lTextes of field "alertes"
end